package com.lpw.dbvideo.video.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lpw.dbvideo.video.dao.VideoMapper;
import com.lpw.dbvideo.video.domain.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class VideoServiceImpl implements VideoService{

    @Autowired
    private VideoMapper videoMapper;
    @Override
    public PageInfo<Video> findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Video> videos = videoMapper.findAll();
        PageInfo<Video> pageInfo = new PageInfo<>(videos);
        return pageInfo;
    }

    @Override
    public Video findById(int id) {
        return videoMapper.findById(id);
    }

    @Override
    public int update(Video video) {
        return videoMapper.update(video);
    }

    @Override
    public int delet(int id) {
       return videoMapper.delet(id);
    }

    @Override
    public int save(Video video) {
        System.out.printf(video.toString());
        return videoMapper.save(video);
    }
}
